<?php

$name = $_POST['name'];

if (($handle = fopen("uploads/$name", "r")) !== FALSE) {
    $list = array();
    while (($row = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $list[$row[2]][] = $row[0].'_'.$row[1];
    }
    fclose($handle);
}
array_shift($list);

unlink("uploads/$name");

echo json_encode($list);